<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="java.util.List" %>
<%@page import="com.infomanage.service.hr.PersonManageService" %>
<%@page import="com.infomanage.po.Person" %>
<%@page import="com.jiuqi.util.ReturnObject"%>
<%  response.addDateHeader("Expires", 0);response.setHeader("Pragma","no-cache"); response.setHeader("Cache-Control","no-cache");%>
<%
    request.setCharacterEncoding("UTF-8");
	String personId = request.getParameter("personId");
    String actionType = request.getParameter("actionType");
    if("add".equals(actionType)){
		ReturnObject ret = (ReturnObject)PersonManageService.savePersonBaseInfo(request,response,out);
		     if(ret.errored()){
			    out.println("<script language='javascript'>");
			    String message = ret.getErrorMessage();
			    if(message != null){
			    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
			    }
			    out.println("  alert('新增员工出错：" + message +"')");
			    out.println("</script>");
			  }else{
			    out.println("<script language='javascript'>");
			    out.println("  alert('新增员工成功！')");
			    out.println("  parent.parent.personGenerateId = "+ ret.getErrorMessage() +";");
			    out.println("</script>");
			  }
    }else if("degreeSave".equals(actionType)){
    	ReturnObject ret = (ReturnObject)PersonManageService.savePersonDegreeInfo(request,response,out);
	     if(ret.errored()){
			    out.println("<script language='javascript'>");
			    String message = ret.getErrorMessage();
			    if(message != null){
			    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
			    }
			    out.println("  alert('保存出错：" + message +"')");
			    out.println("</script>");
			  }else{
			    out.println("<script language='javascript'>");
			    out.println("  alert('保存学历情况成功！')");
			    out.println("</script>");
			  }
    }else if("resumeSave".equals(actionType)){
    	ReturnObject ret = (ReturnObject)PersonManageService.savePersonResumeInfo(request,response,out);
	     if(ret.errored()){
			    out.println("<script language='javascript'>");
			    String message = ret.getErrorMessage();
			    if(message != null){
			    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
			    }
			    out.println("  alert('保存出错：" + message +"')");
			    out.println("</script>");
			  }else{
			    out.println("<script language='javascript'>");
			    out.println("  alert('保存个人简历成功！')");
			    out.println("</script>");
			  }
   }else if("familySave".equals(actionType)){
   	ReturnObject ret = (ReturnObject)PersonManageService.savePersonFamilyInfo(request,response,out);
    if(ret.errored()){
		    out.println("<script language='javascript'>");
		    String message = ret.getErrorMessage();
		    if(message != null){
		    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
		    }
		    out.println("  alert('保存出错：" + message +"')");
		    out.println("</script>");
		  }else{
		    out.println("<script language='javascript'>");
		    out.println("  alert('保存家庭情况成功！')");
		    out.println("</script>");
		  }
	}else if("rewardSave".equals(actionType)){
	ReturnObject ret = (ReturnObject)PersonManageService.savePersonRewardInfo(request,response,out);
    if(ret.errored()){
		    out.println("<script language='javascript'>");
		    String message = ret.getErrorMessage();
		    if(message != null){
		    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
		    }
		    out.println("  alert('保存出错：" + message +"')");
		    out.println("</script>");
		  }else{
		    out.println("<script language='javascript'>");
		    out.println("  alert('保存奖励情况成功！')");
		    out.println("</script>");
		  }
	}else if("studySave".equals(actionType)){
		ReturnObject ret = (ReturnObject)PersonManageService.savePersonStudyInfo(request,response,out);
	    if(ret.errored()){
			    out.println("<script language='javascript'>");
			    String message = ret.getErrorMessage();
			    if(message != null){
			    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
			    }
			    out.println("  alert('保存出错：" + message +"')");
			    out.println("</script>");
			  }else{
			    out.println("<script language='javascript'>");
			    out.println("  alert('保存学习培训信息成功！')");
			    out.println("</script>");
			  }
		}else if("modifyBaseInfo".equals(actionType)){
    	ReturnObject ret = (ReturnObject)PersonManageService.modifyPersonBaseInfo(request,response,out);
	     if(ret.errored()){
			    out.println("<script language='javascript'>");
			    String message = ret.getErrorMessage();
			    if(message != null){
			    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
			    }
			    out.println("  alert('保存出错：" + message +"')");
			    out.println("</script>");
			  }else{
			    out.println("<script language='javascript'>");
			    out.println("  alert('修改员工基本信息成功！')");
			    out.println("</script>");
			  }
    }else if("del".equals(actionType)){
    	  ReturnObject ret = (ReturnObject)PersonManageService.removePersonBaseInfo(request,response,out);
		  if(ret.errored()){
			    out.println("<script language='javascript'>");
			    String message = ret.getErrorMessage();
			    if(message != null){
			    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
			    }
			    out.println("  alert('删除员工出错：" + message +"')");
			    out.println("</script>");
			  }else{
			    out.println("<script language='javascript'>");
			    out.println("  parent.window.location.reload();");
			    out.println("</script>");
			  }
    }else if("delBatch".equals(actionType)) {
    	ReturnObject ret = PersonManageService.removeBatchPersonBaseInfo(request, response, out);
		  if(ret.errored()){
			    out.println("<script language='javascript'>");
			    String message = ret.getErrorMessage();
			    if(message != null){
			    	message = message.replaceAll("'", "\\\\'").replaceAll("\\r|\\n", "");
			    }
			    out.println("  alert('删除员工出错：" + message +"')");
			    out.println("</script>");
			  }else{
			    out.println("<script language='javascript'>");
			    out.println("  alert('删除员工成功！')");
			    out.println("  parent.window.location.reload();");
			    out.println("</script>");
			  }
	}
%>
